/* test Double Linked List */

#include <stdio.h>
#include <stdlib.h>

#include "mex.h"
//#include "dlinkedlists.h"
#include "fibheap.h"

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, 
  const mxArray *prhs[]) {

    DoublyLinkedNode* node[10];
    DoublyLinkedList* l;
    fibNode * value[10];
    
    value[0] = malloc(sizeof(fibNode));
    value[0]->key = 1;
    node[0] = dll_new_node(value[0]);
    value[1] = malloc(sizeof(fibNode));
    value[1]->key = 2;
    node[1] = dll_new_node(value[1]);
    value[2] = malloc(sizeof(fibNode));
    value[2]->key = 3;
    node[2] = dll_new_node(value[2]);
    value[3] = malloc(sizeof(fibNode));
    value[3]->key = 4;
    node[3] = dll_new_node(value[3]);
    value[4] = malloc(sizeof(fibNode));
    value[4]->key = 5;
    node[4] = dll_new_node(value[4]);
    value[5] = malloc(sizeof(fibNode));
    value[5]->key = 6;
    node[5] = dll_new_node(value[5]);
    value[6] = malloc(sizeof(fibNode));
    value[6]->key = 7;
    node[6] = dll_new_node(value[6]);
    value[7] = malloc(sizeof(fibNode));
    value[7]->key = 8;
    node[7] = dll_new_node(value[7]);
    value[8] = malloc(sizeof(fibNode));
    value[8]->key = 9;
    node[8] = dll_new_node(value[8]);
    value[9] = malloc(sizeof(fibNode));
    value[9]->key = 10;
    node[9] = dll_new_node(value[9]);
    
    l = dll_new_list();
    dll_debug(l);
    
    dll_insertEnd(l,node[0]);
    dll_debug(l);
    dll_insertEnd(l,node[1]);
    dll_debug(l);
    
    dll_insertBeginning(l,node[2]);
    dll_debug(l);
    
    dll_insertEnd(l,node[3]);
    dll_debug(l);
    
    dll_remove(l,node[1]);
    dll_debug(l);
    
    dll_insertBeginning(l,node[4]);
    dll_debug(l);
    
    dll_remove(l,node[0]);
    dll_debug(l);
    
    dll_free_list(l);
}